package com.gugee.tiktok.data.consumer.comment.config;

import com.gugee.tiktok.data.common.config.KafkaProducerCommon;
import com.gugee.tiktok.data.common.msg.AwemeMessage;
import com.gugee.tiktok.data.common.msg.CommentMessage;
import com.gugee.tiktok.data.common.msg.FansPortraitMessage;
import com.gugee.tiktok.data.common.msg.KeywordMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.core.KafkaTemplate;


/**
 *
 * @author luolifeng
 * Date  2020/10/27
 */
@Configuration
@EnableKafka
public class KafkaProducerCommentConfig {
    @Autowired
    KafkaProducerCommon kafkaProducerCommon;

    @Bean
    public KafkaTemplate<Long, CommentMessage> kafkaTemplateComment() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(CommentMessage.MsgSerializer.class));
    }
    @Bean
    @ConditionalOnMissingBean
    public KafkaTemplate<Long, KeywordMessage> kafkaTemplateKeyword() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(KeywordMessage.MsgSerializer.class));
    }
    @Bean
    @ConditionalOnMissingBean
    public KafkaTemplate<Long, FansPortraitMessage> kafkaTemplateFansPortrait() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(FansPortraitMessage.MsgSerializer.class));
    }
    @Bean
    public KafkaTemplate<Long, AwemeMessage> kafkaTemplateAweme() {
        return new KafkaTemplate<>(kafkaProducerCommon.myKafkaProducerFactory(AwemeMessage.MsgSerializer.class));
    }
}
